{template 'web/_header'}
{template 'web/statistics/tabs'}
<div class="panel panel-info">
    <div class="panel-heading">
         按年、月、日统计商城交易额、交易量
    </div>
    <div class="panel-body">

        <form action="./index.php" method="get" class="form-horizontal">
            <input type="hidden" name="c" value="site" />
            <input type="hidden" name="a" value="entry" />
            <input type="hidden" name="m" value="sz_yi" />
            <input type="hidden" name="do" value="statistics" />
            <input type="hidden" name="p"  value="sale" />

            <div class="form-group">
                <label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">日期</label>
                <div class="col-sm-1">
                    <select name="year" class="form-control">
                        {loop $years $y}
                        <option value="{$y['data']}"  {if $y['selected']}selected="selected"{/if}>{$y['data']}年</option>
                        {/loop}
                    </select>
                </div>
              
                <div class="col-sm-1">
                    <select name="month" class="form-control">
                        <option value=''>未选月份</option>
                        {loop $months $m}
                        <option value="{$m['data']}"  {if $m['selected']}selected="selected"{/if}>{$m['data']}月</option>
                        {/loop}
                    </select>
                </div>
                 <div class="col-sm-1">
                    <select name="day" class="form-control">
                        <option value=''>未选日期</option>
                    </select>
                </div>
                <span class='help-block'>不选择月份表示年统计，不选择日，则表示月统计</span>
            </div>
            <div class="form-group">
                <label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">类型</label>
                <div class="col-sm-8 col-lg-9 col-xs-12">
                    <label class="radio-inline"><input type="radio" name="type" value="0" {if $_GPC['type'] == 0}checked=""{/if}>交易额</label>
                    <label class="radio-inline"><input type="radio" name="type" value="1" {if $_GPC['type'] == 1}checked=""{/if}>交易量</label>
                </div>
            </div>
            <div class="form-group">
                <label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label"></label>
                <div class="col-sm-8 col-lg-9 col-xs-12">
                    <button class="btn btn-default" ><i class="fa fa-search"></i> 搜索</button>
                    <input type="hidden" name="token" value="{$_W['token']}" />
                    {if 'statistics.export.sale'}
                    <button type="submit" name="export" value='1' class="btn btn-primary">导出 Excel</button>
                    {/if}
                </div>

            </div>

            <div class="form-group">
            </div>
        </form>
    </div>
</div>
<div class="panel panel-default">
    <div class='panel-heading'>
        数据统计 
        {if empty($type)}交易额{else}交易量{/if}总数：<span style="color:red; ">{$totalcount}</span>，
        最高{if empty($type)}交易额{else}交易量{/if}：<span style="color:red; ">{$maxcount}</span> {if !empty($maxcount_date)}<span>({$maxcount_date}</span>){/if}
       
    </div>
    <div class="panel-body">
        <table class="table table-hover">
            <thead>
                <tr>
                    <th style='width:100px;'>
                        {if empty($_GPC['month'])}月份{else}日期{/if}
                    </th>
                    <th style='width:200px;'>{if empty($type)}交易额{else}交易量{/if}</th>
                    <th>所占比例</th>
                </tr>
            </thead>
            <tbody>
                {loop $list $row}
                <tr>
                    <td>{$row['data']}</td>
                    <td>{$row['count']}</td>
                    <td>
                       <div class="progress" style='max-width:500px;' >
                           <div style="width: {$row['percent']}%;" class="progress-bar progress-bar-info" ><span style="color:#000">{php echo empty($row['percent'])?'':$row['percent'].'%'}</span></div>
                       </div>
                    </td>
                </tr>
                {/loop}
            </tbody>
        </table>   
    </div>
</div>
<script language='javascript'>
    function get_days(){
          
        var year = $('select[name=year]').val();
        var month =$('select[name=month]').val();
        var day  = $('select[name=day]');
       day.get(0).options.length = 0 ;
        if(month==''){
	   day.append("<option value=''>未选日期</option");
            return;
        }
       
        day.get(0).options.length = 0 ;
        day.append("<option value=''>计算天数...</option").attr('disabled',true);
        $.post("{php echo $this->createWebUrl('statistics/util',array('op'=>'days'))}",{year:year,month:month},function(days){
             day.get(0).options.length = 0 ;
             day.removeAttr('disabled');
             days =parseInt(days);
             day.append("<option value=''>未选日期</option");
             for(var i=1;i<=days;i++){
                 day.append("<option value='" + i +"'>" + i + "日</option");
             }
          
             {if !empty($day)}
                day.val( {$day});
             {/if}
        })
        
    }
    $('select[name=month]').change(function(){
           get_days();
    })
    
    get_days();
 </script>
{template 'web/_footer'}
